 Page({
 	data: {
 		inputValue: '',
 		loading_status: true,
 		image: '../Wenda/1.jpg',

 	},
 	onLoad: function () {},
 	inputChange(e) {
 		this.setData({
 			inputValue: e.detail.value
 		})
 	},
 	confirm() {
 		const inputValue = this.data.inputValue;
 		this.getToken_A(inputValue)
 	},

 	getToken_A(inputValue) {
 		var ls = this.data.loading_status
 		this.setData({
 			loading_status: !ls
 		})
 		console.log("判断是" + ls)
 		console.log("正在执行getToken_A" + inputValue)

 		const url_token = "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=Zr0exdXDxEOqWKm7m7tPucdj&client_secret=9sYsg6ORMAiuwx2q1OaEo37siFuqjvpO";

 		wx.request({
 			url: "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=Zr0exdXDxEOqWKm7m7tPucdj&client_secret=9sYsg6ORMAiuwx2q1OaEo37siFuqjvpO",
 			method: "POST",
 			header: {
 				'Content-Type': 'application/json',
 				'Accept': 'application/json'
 			},
 			success: res => {

 				const access_token = res.data.access_token
 				console.log("TOKEN:" + access_token)
 				const url_chat = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro?access_token=24.15c08996c1a13f15b5872994f6f967e9.2592000.1708518826.282335-42141735"

 				const payload = {
 					"messages": [{
 						"role": "user",
 						"content": "简答：" + inputValue
 					}]
 				};

 				wx.request({
 					url: url_chat,
 					method: "POST",
 					data: payload,
 					header: {
 						'Content-Type': 'application/json'
 					},

 					success: (res) => {
 						console.log(res.data, typeof (res.data));
 						this.setData({
 							result_A: res.data,
 							loading_status: true
 						})

 					},

 				});
 			},
 		});
 	},

 });